using System;
using System.Collections.Generic;

namespace InfiniTec.Threading
{
    public class ParallelOperation : OperationAction
    {
        private readonly List<NestedOperation> _Operations;
        private int _MaximumParallelOperations;


        public int MaximumParallelOperations { get { return _MaximumParallelOperations; } set { _MaximumParallelOperations = value; } }

        public List<NestedOperation> Operations { get { return _Operations; } }


        public ParallelOperation(IEnumerable<NestedOperation> operations): this(int.MaxValue, operations) { }

        public ParallelOperation(int maximumParallelOperations, IEnumerable<NestedOperation> operations)
        {
            if (operations == null){ throw new ArgumentNullException("operations"); }

            _Operations = new List<NestedOperation>(operations);

            _MaximumParallelOperations = maximumParallelOperations;
        }


        public ParallelOperation(int maximumParallelOperations, params NestedOperation[] operations): 
            this(maximumParallelOperations, (IEnumerable<NestedOperation>) operations)
        {
        }

        public ParallelOperation(params NestedOperation[] operations)
            : this((IEnumerable<NestedOperation>)operations)
        {
        }
    }
}